package org.hxzon.demo.scala.matchdemo

object RegexMatch {
  def process(input: String) {
    val MatchStock = """^(.+):(\d*\.\d+)""".r
    input match {
      case MatchStock("GOOG", price) => println("Price of GOOG is " + price)
      case MatchStock("IBM", price) => println("IBM's trading at " + price)
      case MatchStock(symbol, price) => printf("Price of %s is %s\n", symbol, price)
      case _ => println("not processing " + input)
    }
  }
  def main(args: Array[String]): Unit = {
    process("GOOG:310.84") //Price of GOOG is 310.84
    process("IBM:84.01") //IBM's trading at 84.01
    process("GE:15.96") //Price of GE is 15.96
    process("APPLE:ORANGE") //not processing APPLE:ORANGE
  }
}
